package com.xu.CAS;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.concurrent.atomic.AtomicReference;

/**
 *
 * @author xudenghui
 * @create 2023-02-27 16:35
 **/
public class AtomicReferenceDemo {
    public static void main(String[] args) {
//        AtomicReference<User> userAtomicReference = new AtomicReference<>();
//        User hgw = new User("hgw", 22);
//        User hly = new User("hly", 22);
//        userAtomicReference.set(hly);
//        System.out.println(userAtomicReference.compareAndSet(hly, hgw)+"\t"+userAtomicReference.get());
//        System.out.println(userAtomicReference.compareAndSet(hly, hgw)+"\t"+userAtomicReference.get());

    }

    @Data
    @AllArgsConstructor
    private static class User {
        String userName;
        int age;

    }
}
